<html>
<head>
<script>
var xmlhttp;
var url;
var taux;

function request(){
	chrome.browserAction.setTitle({title:localStorage["fromCurrency"]+"-"+localStorage["toCurrency"]});
	url="https://www.google.com/ig/calculator?q=1"+localStorage["fromCurrency"]+"=?"+localStorage["toCurrency"];
	xmlhttp = new XMLHttpRequest();
	xmlhttp.onreadystatechange=state_Change;
	xmlhttp.open("GET",url,true);
	xmlhttp.send();
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {
  if (xmlhttp.status==200)
    {
		var resp = eval("(" + xmlhttp.responseText + ")");
		taux=resp.rhs.substring(0,6);
		chrome.browserAction.setBadgeText({text:String(taux)});
    }
  else
    {
		chrome.browserAction.setBadgeText({text:String("e"+xmlhttp.status)});  
		
    }
  }
else
	chrome.browserAction.setBadgeText({text:String("E"+xmlhttp.readyState)}); 
}
//first time
if(localStorage["fromCurrency"]==null){
	localStorage["fromCurrency"]="EUR";
	localStorage["toCurrency"]="CNY";
	}
request();//first time	  
window.setInterval("request()", 600000);

</script>
</head>
</html>
